import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [{
  path: '/',
  redirect: '/movie'
}, {
  path: '/movie',
  name: 'movie',
  component: () => import('@/views/Movie'),

  children: [{
      path: '/movie',
      redirect: '/movie/nowPlaying',

    }, {
      path: 'city',
      name: 'city',
      component: () => import('@/components/Movie/City')
    },
    {

      path: 'nowPlaying',
      name: 'nowPlaying',
      component: () => import('@/components/Movie/NowPlaying')
    },
    {
      path: 'comingSoon',
      name: 'comingSoon',
      component: () => import('@/components/Movie/ComingSoon')
    },
    {
      path: 'search',
      name: 'search',
      component: () => import('@/components/Movie/Search')
    },
    {
      // 命名视图需要使用components
      path: 'detail/1/:movieid',
      components: {
        default: () => import('@/components/Movie/NowPlaying'),
        detail: () => import('@/views/Movie/detail')
      },
      // 直接在详情页接收到movieid props: ['movieId']
      props: {
        detail: true
      }
    },
    {
      // 命名视图需要使用components
      path: 'detail/2/:movieid',
      components: {
        default: () => import('@/components/Movie/ComingSoon'),
        detail: () => import('@/views/Movie/detail')
      },
      // 直接在详情页接收到movieid props: ['movieId']
      props: {
        detail: true
      }
    }
  ]
}, {
  path: '/mine',
  name: 'mine',
  component: () => import('@/views/Mine')
}, {
  path: '/cinema',
  name: 'cinema',
  component: () => import('@/views/Cinema')
}]

const router = new VueRouter({
  mode: 'history',
  // base: process.env.BASE_URL,
  base: 'miaomiao',
  routes
})

export default router